import ToolAction from "@/tool/http/tool-action.js";
import ToolUni from "@/tool/ToolUni";

export default {
	namespaced: true,
	state: {
		areas: ToolUni.storage("n-area")
	},
	mutations: {
		updateArea: (state, areas) => {
			state.areas = areas;
			ToolUni.storage("n-area", areas);
		}
	},
	actions: {
		async listArea(context) {
			if (context.state.areas && context.state.areas.length > 0) {
				return context.state.areas;
			}
			let res = await ToolAction.run("action-area-list", "63705362eaed4cafa7fa798403b18272");
			context.commit("updateArea", [res]);
			return [res];
		}
	}
}
